//
//  KYPublicHomeView.m
//  kuaiyi
//
//  Created by 杨亮 on 16/3/17.
//  Copyright © 2016年 kuaiyi. All rights reserved.
//

#import "KYPublicHomeView.h"
#import "Header.h"
#import <Masonry.h>
#import "KYPublicHomeView.h"

@implementation KYPublicHomeView

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self setUpUI];
    }
    return self;
}
#define publicColor [UIColor colorWithRed:0 green:192/255.0 blue:240/255.0 alpha:1]
-(void)setUpUI{
    
    self.backgroundColor = [UIColor colorWithRed:235/255.0 green:250/255.0 blue:250/255.0 alpha:1];
    UILabel *bigLabel = [[UILabel alloc]init];
    bigLabel.text = @"脑瘫患儿公益援助基金";
    bigLabel.textColor = publicColor;
    bigLabel.font = [UIFont systemFontOfSize:30];
    bigLabel.textAlignment = NSTextAlignmentCenter;
    
    UIButton *applyBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [applyBtn setTitle:@"申请援助" forState:UIControlStateNormal];
    [applyBtn setBackgroundColor:publicColor];
    applyBtn.layer.cornerRadius = 5;
    applyBtn.layer.masksToBounds = YES;
    [applyBtn addTarget:self action:@selector(applyBtnKlick) forControlEvents:UIControlEventTouchUpInside];
    
    UIButton *aboutBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [aboutBtn setTitle:@"关于基金" forState:UIControlStateNormal];
    [aboutBtn setBackgroundColor:[UIColor whiteColor]];
    [aboutBtn setTitleColor:publicColor forState:UIControlStateNormal];
    aboutBtn.layer.cornerRadius = 5;
    aboutBtn.layer.masksToBounds = YES;
    aboutBtn.layer.borderColor = (__bridge CGColorRef _Nullable)(publicColor);
    [aboutBtn addTarget:self action:@selector(aboutBtnKlick) forControlEvents:UIControlEventTouchUpInside];
    
    UIImageView *heartImage = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"content_img_01"]];
    [heartImage sizeToFit];
    
    UIImageView *childImage = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"content_img_02"]];
    [childImage sizeToFit];
    
    UIImageView *numberImage = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"content_img_03"]];
    
    [self addSubview:bigLabel];
    [self addSubview:applyBtn];
    [self addSubview:aboutBtn];
    [self addSubview:heartImage];
    [self addSubview:childImage];
    [self addSubview:numberImage];
    
    [bigLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.mas_top).offset(30);
        make.centerX.equalTo(self.mas_centerX);
    }];
    [applyBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(bigLabel.mas_bottom).offset(40);
        make.centerX.equalTo(self.mas_centerX);
        make.width.equalTo(@200);
    }];
    [aboutBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(applyBtn.mas_bottom).offset(15);
        make.centerX.equalTo(self.mas_centerX);
        make.width.equalTo(applyBtn.mas_width);
    }];
    [heartImage mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(aboutBtn.mas_bottom).offset(50);
        make.centerX.equalTo(self.mas_centerX);
    }];
    [childImage mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(heartImage.mas_bottom).offset(40);
        make.centerX.equalTo(self.mas_centerX);
    }];
    [numberImage mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(childImage.mas_bottom).offset(20);
        make.centerX.equalTo(self.mas_centerX);
    }];
    
}
-(void)applyBtnKlick{
    [[NSNotificationCenter defaultCenter]postNotificationName:changeViewNotification object:nil userInfo:@{changeViewKey:@"applyBtnKlick"}];
}
-(void)aboutBtnKlick{
    
}
@end
